import os
import subprocess
import platform
import pandas as pd


def reveal_in_explorer(path, type='all'):
    if path == '':
        return

    if type != 'file' and os.path.isdir(path):
        if system == 'Windows':
            cmd = 'explorer.exe'
            path = path.replace('/', '\\')
        else:
            cmd = 'open'

        try:
            subprocess.Popen([cmd, path])

        except IOError:
            print('Can\'t open the dir: ' + path)

    elif type != 'dir' and os.path.isfile(path):
        try:
            if system == 'Windows':
                os.startfile(path)
            else:
                subprocess.Popen(['open', path])

        except IOError:
            print('Can\'t open the file: ' + path)

    else:
        print('Can\'t open: ' + path)


system = platform.system()
